import HTMLParser
import urllib
import re


urlString="http://www.s-ix.info/Teilnehmer.htm"
check=False
urlText=[]

class ParseIXP(HTMLParser.HTMLParser):
    def handle_starttag(self,tag,attrs):
        global check
        if tag=="font":
            for name,value in attrs:
                if name=="size" and value=="2":
                    check=True
        
             
    def handle_data(self,data):
        global check
        if data!='\n' and check==True:
            data=data.replace("\t","")
            data=data.replace(chr(13),"")
            data=data.replace(chr(10),"")
            if(re.search("^[A][S]\d\d*$",data)):
                number=data.replace("AS","")
                urlText.append(number)
                check=False   
            
lparser=ParseIXP()
lparser.feed(urllib.urlopen(urlString).read())
filePath="ixp_members.txt"
file = open(filePath,"a")
for item in urlText:
    #print item
    print >> file, "112 %s" % item
file.close()